package com.coolw.data.migrate.common.listener.event;

import lombok.Getter;
import org.dromara.hutool.core.data.id.IdUtil;
import org.springframework.context.ApplicationEvent;

/**
 * 事件基类
 *
 * @author coolw
 * @date 2024/2/21 12:51
 */
@Getter
public class BaseEvent<T> extends ApplicationEvent {
    private static final long serialVersionUID = -86526802237791228L;

    /**
     * 事件ID
     */
    private final String eventId;

    /**
     * 事件类型
     */
    private final EventTypeEnum eventType;

    /**
     * 事件数据
     */
    private final T eventData;

    /**
     * 请求参数
     */
    private final String reqParam;

    public BaseEvent(Object source, EventTypeEnum eventType, T eventData) {
        this(source, eventType, eventData, null);
    }

    public BaseEvent(Object source, EventTypeEnum eventType, T eventData, String reqParam) {
        super(source);
        this.eventId = IdUtil.fastSimpleUUID();
        this.eventType = eventType;
        this.eventData = eventData;
        this.reqParam = reqParam;
    }
}
